/**
 * @author: yasen
 * @time: 2022/10/11 10:56
 * @email: yasen@yasenstudio.com
 */
package org.example;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class ConsumerRecordDAOImpl implements ConsumerRecordDAO {
    private Connection connection;
    private PreparedStatement preparedStatement;
    public ConsumerRecordDAOImpl(Connection connection) {
        this.connection = connection;
    }
    @Override
    public <K, V> void create(K key, V value) {
        try {
            String sql = "INSERT INTO ar.t_simple_kv (record_key, record_value) VALUES (?, ?);";
            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1, key.toString());
            preparedStatement.setString(2, value.toString());
            preparedStatement.execute();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
